package com.axin.common.exception;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import com.axin.common.entity.JsonResult;

/**
 * 全局异常处理类
 * @Description: TODO 
 * @ClassName:  ControllerExceptionHandler
 * @author:  Axin 
 * @date:   2019年3月11日 下午10:14:26   
 * @Copyright: 2019 www.hao456.top Inc. All rights reserved.
 */

@ControllerAdvice //此注解用于标识此类为全局异常处理类
public class ControllerExceptionHandler {
	
	@ExceptionHandler(Exception.class)
	@ResponseBody
	public JsonResult handleException(Exception e){
		e.printStackTrace();
		return new JsonResult(e);
	}
	
	
	@ExceptionHandler(RuntimeException.class)
	@ResponseBody
	public JsonResult handleException(RuntimeException e){
		e.printStackTrace();
		return new JsonResult(e);
	}

}
